<template>
	<view class="container">
		<view class="form">
			<view class="title">注册</view>
			<input class="input" v-model="username" type="text" placeholder="请输入用户名" />
			<input class="input" v-model="password" type="password" placeholder="请输入密码" />
			<input class="input" v-model="rePassword" type="password" placeholder="请确保密码" />
			<button class="btn" type="primary" @click="handleRegister">注册</button>
			<view class="bottom">
				<text>没有账号？</text>
				<navigator class="register-link" url="/pages/login/login">去登录</navigator>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				username: '',
				password: '',
				rePassword: ''
			}
		},
		methods: {
			handleRegister() {
				if (!this.username || !this.password) {
					uni.showToast({
						title: '请输入完整信息',
						icon: 'none'
					})
					return
				}

				if (this.password !== this.rePassword) {
					uni.showToast({
						title: '两次输入的密码不一致',
						icon: 'none'
					})
					return
				}
				uni.navigateTo({
					url: "/pages/login/login"
				})
			}

		}
	}
</script>

<style>
	.container {
		height: 550px;
		display: flex;
		justify-content: center;
		align-items: center;
		background-color: #f5f5f5;
	}

	.form {
		background-color: white;
		padding: 20px;
		border-radius: 8px;
		box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
		width: 90%;
		max-width: 300px;
	}

	.title {
		text-align: center;
		margin-bottom: 20px;
		font-size: 24px;
		color: #333;
	}

	.input {
		display: block;
		width: 90%;
		padding: 10px;
		margin-bottom: 15px;
		border: 1px solid #ccc;
		border-radius: 4px;
		font-size: 16px;
	}

	.btn {
		display: block;
		width: 100%;

		background-color: #007AFF;
		color: white;
		border: none;
		border-radius: 4px;
		font-size: 18px;
		cursor: pointer;
		margin-top: 20px;
	}

	.btn:hover {
		background-color: #0056b3;
	}

	.bottom {
		display: flex;
		justify-content: center;
		align-items: center;
		margin-top: 20px;
		font-size: 14px;
		color: #666;
	}

	.register-link {
		color: #007bff;
		cursor: pointer;
	}
</style>